package com.tedu.egmybaits1.mapper;

import com.tedu.egmybaits1.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper

public interface ProductMapper {
    @Insert("INSERT INTO product(title,price,stock) VALUES " +
            " (#{title},#{price},#{stock})")
    int insert(Product product);

    @Delete("DELETE FROM product WHERE id=#{id}")
    int deleteById(Integer id);

    @Update("UPDATE product SET title=#{title},price=#{price},stock=#{stock} WHERE id=#{id}")
    int updateById(Product product);

    @Select("SELECT title,price,stock FROM product WHERE id = #{id} ")
    Product selectById(Integer id);

    @Select("SELECT title,price,stock FROM product ")
    List<Product> selectAll();
}
